package com.hr.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hr.util.VerifyCodeUtils;


@RestController
@RequestMapping("/VerifyCode")
public class VerifyCodeControl {
	
    /**
     * get
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
	@RequestMapping("/getVerifyCode")
    public void getVerifyCode(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setHeader("Cache-Control", "no-store, no-cache");
        resp.setContentType("image/jpeg");
        String capText = VerifyCodeUtils.generateVerifyCode(4);
        req.getSession().setAttribute("VerifyCode", capText);
        VerifyCodeUtils.outputImage(180,60,resp.getOutputStream(),capText);
    }
}
